#ifndef COMMANDHISTORY_HPP
#define COMMANDHISTORY_HPP

/**
 * The command history, accessed through up/down arrow.
 * Whenever the user arrows up or down, or commits a command, the up(), down()
 * or commit() function gets called, with the text that was typed at the time.
 * If you arrow back, edit a history entry, then arrow again without
 * committing, the modified history entry will be saved in its place; if that
 * entry is then later committed, the original unmodified entry will be
 * restored.
 */
class CommandHistory
{
public:
	CommandHistory();
	~CommandHistory();
	string up(string typed);
	string down(string typed);
	void commit(string typed);
	
protected:
	struct HistoryEntry
	{
		HistoryEntry();
		~HistoryEntry();
		char *currentText;
		char *originalText;
	};
	
	void updateEntry(const string &typed);
	int historyPos;
	deque<HistoryEntry*> history;
};

#endif
